import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import be.ipl.diavoloz.dao.DeDao;
import be.ipl.diavoloz.dao.DemonsDao;
import be.ipl.diavoloz.dao.JoueurDao;
import be.ipl.diavoloz.dao.PartieDao;
import be.ipl.diavoloz.dao.TourDao;
import be.ipl.diavoloz.modele.Joueur;
import be.ipl.diavoloz.usecases.GestionInscription;


public class GestionInscriptionTest {

	private static GestionInscription gi;
	private Joueur j1 = new Joueur("pseudo3", 1, "email3", "mdp3");
	private Joueur j2 = new Joueur("pseudo4", 2, "email4", "mdp4");
	
	@EJB
	JoueurDao joueurDao;
	@EJB
	PartieDao partieDao;
	@EJB
	DemonsDao demonDao;
	@EJB
	DeDao deDao;
	@EJB
	TourDao tourDao;
	
	@BeforeClass
	public static void setUpBeforeClass() {
		try {
			Context jndi = new InitialContext();
			gi = (GestionInscription) jndi.lookup("ejb:diavoloZ_EAR/diavoloZ_EJB/GestionInscriptionImpl!be.ipl.diavoloz.usecases.GestionInscription");
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
	}
	
	@Before
	public void before(){
		
	}
	
	@After
	public void after(){
	}
	
	@Test
	public void testSinscrire() {
		assertTrue(gi.sinscrire(j1.getPseudo(), j1.getEmail(), j1.getAge(), j1.getMdp()));
		assertFalse(gi.sinscrire(j1.getPseudo(), j1.getEmail(), j1.getAge(), j1.getMdp()));		
		assertFalse(gi.sinscrire(j2.getPseudo(), j1.getEmail(), j2.getAge(), j2.getMdp()));
		assertFalse(gi.sinscrire(j1.getPseudo(), j2.getEmail(), j2.getAge(), j2.getMdp()));	
	}

}
